package com.ccnf.web.controller;

import com.ccnf.core.bean.Response;
import com.ccnf.core.bean.ResponseWithData;
import com.ccnf.model.entity.Expo;
import com.ccnf.service.ExpoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(value = "ExpoController", description = "展会相关API")
@RestController
@RequestMapping("/expos")
public class ExpoController {
    @Autowired
    private ExpoService expoService;

    @ApiOperation("录入展会信息")
    @PostMapping
    public Response insert(@RequestBody Expo expo) {
        expoService.saveExpo(expo);
        return Response.success();
    }

    @ApiOperation("通过展会ID获取展会信息")
    @GetMapping("{expoId}")
    public ResponseWithData expoInfo(@PathVariable Long expoId) {
        return ResponseWithData.success(expoService.findExpoByExpoId(expoId));
    }

    @ApiOperation("通过展会ID获取展会信息")
    @GetMapping("channelCode/{channelCode}")
    public ResponseWithData expoInfo(@PathVariable String channelCode) {
        return ResponseWithData.success(expoService.findExpoByChanelCode(channelCode));
    }
}